<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
  <head>
    <th:block th:replace="~{/_include/header}" />
    <meta name="page-help" content="https://getrebuild.com/docs/admin/transforms" />
    <title>[[${bundle.L('记录转换')}]]</title>
    <link rel="stylesheet" type="text/css" th:href="@{/assets/css/transform-design.css}" />
  </head>
  <body>
    <div class="rb-wrapper rb-fixed-sidebar rb-collapsible-sidebar rb-collapsible-sidebar-hide-logo rb-color-header" th:classappend="${sideCollapsedClazz}">
      <th:block th:replace="~{/_include/nav-top}" />
      <th:block th:replace="~{/_include/nav-left-admin(active='robot-transforms')}" />
      <div class="rb-content">
        <div class="page-head">
          <div class="page-head-title">
            [[${bundle.L('记录转换')}]]
            <span class="sub-title">[[${name ?: bundle.L('未命名')}]]</span>
            <span th:if="${isDisabled}" class="badge badge-grey badge-pill up-1 ml-1">[[${bundle.L('未启用')}]]</span>
          </div>
          <div class="clearfix"></div>
        </div>
        <div class="main-content container-fluid pt-0">
          <div class="card mb-0">
            <div class="card-body">
              <form class="simple">
                <div class="form-group row mt-2">
                  <label class="col-md-12 col-xl-3 col-lg-4 col-form-label text-lg-right">[[${bundle.L('转换条件')}]]</label>
                  <div class="col-md-12 col-xl-9 col-lg-8">
                    <a class="btn btn-sm btn-link pl-0 text-left down-2" id="useFilter">[[${bundle.L('点击设置')}]]</a>
                    <p class="form-text mb-0 mt-0">[[${bundle.L('符合转换条件的记录才允许被转换')}]]</p>
                  </div>
                </div>
                <div class="form-group row">
                  <label class="col-md-12 col-xl-3 col-lg-4 col-form-label text-lg-right">[[${bundle.L('转换字段映射')}]]</label>
                  <div class="col-md-12 col-xl-9 col-lg-8">
                    <ul th:if="${sourceDetailEntity != null}" class="nav nav-tabs mb-2 entities-mapping">
                      <li class="nav-item"><a class="nav-link active" href="#EMAIN" data-toggle="tab">[[${bundle.L('主实体')}]]</a></li>
                      <li class="nav-item"><a class="nav-link" href="#EDETAIL" data-toggle="tab">[[${bundle.L('明细实体')}]]</a></li>
                      <li class="nav-item" th:if="${(sourceDetailEntities != null && sourceDetailEntities.size() > 1) || targetDetailEntities != null && targetDetailEntities.size() > 1}">
                        <a class="nav-link w-auto J_add-dts" th:title="${bundle.L('添加明细转换')}"><i class="icon mdi mdi-plus fs-19 up-2 m-0"></i></a>
                      </li>
                    </ul>
                    <div class="tab-content m-0 p-0 fields-mapping">
                      <div class="tab-pane active" id="EMAIN">
                        <p class="text-muted m-0" style="padding-top: 7px">[[${bundle.L('加载中')}]]</p>
                      </div>
                      <div class="tab-pane" id="EDETAIL"></div>
                    </div>
                  </div>
                </div>
                <div class="form-group row">
                  <label class="col-md-12 col-xl-3 col-lg-4 col-form-label text-lg-right">[[${bundle.L('转换后回填')}]]</label>
                  <div class="col-md-12 col-xl-9 col-lg-8">
                    <div class="col-6 pl-0 pr-0">
                      <select class="form-control form-control-sm" id="fillbackField"></select>
                    </div>
                    <p class="form-text">[[${bundle.L('可将转换后的记录 ID 回填至源记录中')}]]</p>
                  </div>
                </div>
                <th:block th:if="${targetIsDetail}">
                  <div class="form-group row">
                    <label class="col-md-12 col-xl-3 col-lg-4 col-form-label text-lg-right"></label>
                    <div class="col-md-12 col-xl-9 col-lg-8">
                      <label class="custom-control custom-control-sm custom-checkbox custom-control-inline mb-0">
                        <input class="custom-control-input" type="checkbox" id="importsMode" value="2" />
                        <span class="custom-control-label">[[${bundle.L('启用明细记录导入')}]] <sup class="rbv"></sup></span>
                      </label>
                      <p class="form-text">[[${bundle.L('通过此记录转换规则进行明细记录批量导入/添加')}]]</p>
                    </div>
                  </div>
                  <div class="form-group row hide">
                    <label class="col-md-12 col-xl-3 col-lg-4 col-form-label text-lg-right"></label>
                    <div class="col-md-12 col-xl-9 col-lg-8">
                      <div id="filterFields">
                        <h5 class="mt-2 text-bold">[[${bundle.L('明细记录导入规则')}]]</h5>
                        <span></span>
                        <h5 class="mt-3 text-bold">[[${bundle.L('符合规则时自动导入')}]]</h5>
                        <label class="custom-control custom-control-sm custom-checkbox custom-control-inline mb-0">
                          <input class="custom-control-input" type="checkbox" id="importsMode2Auto1" value="1" />
                          <span class="custom-control-label">[[${bundle.L('新建时')}]]</span>
                        </label>
                        <label class="custom-control custom-control-sm custom-checkbox custom-control-inline mb-0">
                          <input class="custom-control-input" type="checkbox" id="importsMode2Auto2" value="2" />
                          <span class="custom-control-label">[[${bundle.L('编辑时')}]]</span>
                        </label>
                      </div>
                    </div>
                  </div>
                </th:block>
                <div class="form-group row footer">
                  <label class="col-md-12 col-xl-3 col-lg-4 col-form-label text-lg-right"></label>
                  <div class="col-md-12 col-xl-9 col-lg-8">
                    <button class="btn btn-primary J_save" type="button">[[${bundle.L('保存')}]]</button>
                  </div>
                </div>
              </form>
            </div>
          </div>
        </div>
      </div>
    </div>
    <th:block th:replace="~{/_include/footer}" />
    <script>
      window.__PageConfig = {
        configId: '[[${configId}]]',
        config: [(${config ?:'null'})],
        sourceEntity: [(${sourceEntity ?:'null'})],
        sourceDetailEntity: [(${sourceDetailEntity ?:'null'})],
        sourceDetailEntities: [(${sourceDetailEntities ?:'null'})],
        targetEntity: [(${targetEntity ?:'null'})],
        targetDetailEntity: [(${targetDetailEntity ?:'null'})],
        targetDetailEntities: [(${targetDetailEntities ?:'null'})],
      }
    </script>
    <script th:src="@{/assets/js/metadata/field-valueset.js}" type="text/babel"></script>
    <script th:src="@{/assets/js/general/rb-advfilter.js}" type="text/babel"></script>
    <script th:src="@{/assets/js/metadata/field-compatible.js}" type="text/babel"></script>
    <script th:src="@{/assets/js/admin/transform-design.js}" type="text/babel"></script>
  </body>
</html>
